package com.test.dababy.dababy_05_process;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.test.dababy.R;

public class DateP_dababyickerDia_dababylog extends BottomSheetDialog {


    private char z22j='v';
    private float zg8G=0.5198928f;
    private String e0Eq="";
    private boolean a382=false;
    private String s740="";
    private boolean pu33=true;
    private char a21z='>';
    private String z0TC="";
    private float i3Qq=0.44019365f;
    private String y1X6="";

    public void z6sFc(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getY1X6())) setZ0TC(getS740()+getI3Qq()+getA21z()+isPu33());
                else setE0Eq(String.valueOf(isA382())+getZg8G()+getZ22j());

            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void setZ22j(char z22j) {
        this.z22j = z22j;
    }

    public void setZg8G(float zg8G) {
        this.zg8G = zg8G;
    }

    public void setE0Eq(String e0Eq) {
        this.e0Eq = e0Eq;
    }

    public void setA382(boolean a382) {
        this.a382 = a382;
    }

    public void setS740(String s740) {
        this.s740 = s740;
    }

    public void setPu33(boolean pu33) {
        this.pu33 = pu33;
    }

    public void setA21z(char a21z) {
        this.a21z = a21z;
    }

    public void setZ0TC(String z0TC) {
        this.z0TC = z0TC;
    }

    public void setI3Qq(float i3Qq) {
        this.i3Qq = i3Qq;
    }

    public void setY1X6(String y1X6) {
        this.y1X6 = y1X6;
    }

    public char getZ22j() {
        return z22j;
    }

    public float getZg8G() {
        return zg8G;
    }

    public String getE0Eq() {
        return e0Eq;
    }

    public boolean isA382() {
        return a382;
    }

    public String getS740() {
        return s740;
    }

    public boolean isPu33() {
        return pu33;
    }

    public char getA21z() {
        return a21z;
    }

    public String getZ0TC() {
        return z0TC;
    }

    public float getI3Qq() {
        return i3Qq;
    }

    public String getY1X6() {
        return y1X6;
    }

    private final String title_dababy;
    private final On_dababyDate_dababyPickListener onDatePickListener_dababy;
    private final Runnable onDismissRunnable;

    public DateP_dababyickerDia_dababylog(Context context, String title, On_dababyDate_dababyPickListener onDatePickListener,Runnable onDismissRunnable){
        super(context, R.style.Theme_Dababy_BottomDialogStyle);
        this.title_dababy = title;
        this.onDatePickListener_dababy = onDatePickListener;
        this.onDismissRunnable = onDismissRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_dababy_date_picker);

        getWindow().setBackgroundDrawableResource(R.color.transparent);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

        init_dababy();
    }

    private void init_dababy(){

        TextView titleTv = findViewById(R.id.dddp_tv_title);
        Button doneBtn = findViewById(R.id.dddp_btn_done);

        titleTv.setText(title_dababy);

        DatePicker datePicker = findViewById(R.id.dddp_datepicker);
        if (datePicker == null) return;
        datePicker.setCalendarViewShown(false);

        z6sFc();

        doneBtn.setOnClickListener(v -> {
            int month = datePicker.getMonth() + 1;
            int day = datePicker.getDayOfMonth();
            String monthStr = month<10 ? "0"+month:String.valueOf(month);
            String dayStr = day<10 ? "0"+day:String.valueOf(day);
            String date = datePicker.getYear()+"-"+monthStr+"-"+dayStr;
            if (onDatePickListener_dababy != null) onDatePickListener_dababy.onDatePick_dababy(date);
            DateP_dababyickerDia_dababylog.this.dismiss();
        });
    }

    @Override
    public void dismiss() {
        if (onDismissRunnable!=null) onDismissRunnable.run();
        super.dismiss();
    }
}
